/*
 * @Author: szx
 * @Date: 2022-03-27 13:07:36
 * @LastEditTime: 2022-03-27 13:10:45
 * @Description:
 * @FilePath: \leetcode\剑指offer\53\53_II.js
 */
/**
 * @param {number[]} nums
 * @return {number}
 */
var missingNumber = function (nums) {
    let i = 0,
        j = nums.length - 1,
        mid;
    while (i <= j) {
        mid = Math.floor((i + j) / 2);
        if (nums[mid] == mid + 1) {
            j = mid - 1;
        } else {
            i = mid + 1;
        }
    }
    return i;
};
console.log(missingNumber([0, 1, 2, 3, 4, 5, 6, 7, 9]));
console.log(missingNumber([0, 1, 3]));
